using Perfect.Marshal;
using System.Xml;

namespace editor
{
namespace cfg.task
{
[System.Serializable]
public  class Linear : Task
 {

    public System.Collections.Generic.List<int> taskIds  = new System.Collections.Generic.List<int>();
     


    public const int TYPE_ID = 758537540;

    public override int GetTypeId() {
        return TYPE_ID;
    }


    public override void MarshalCompatible(Perfect.Marshal.Octets os) {
        os.WriteSize(11);
        os.WriteSize(Tag.INT | (1 << Tag.TAG_SHIFT));  os.WriteInt(id);  
         os.WriteSize(Tag.STRING | (2 << Tag.TAG_SHIFT));  os.WriteString(name);  
         os.WriteSize(Tag.STRING | (3 << Tag.TAG_SHIFT));  os.WriteString(showTypeName);  
         os.WriteSize(Tag.STRING | (4 << Tag.TAG_SHIFT));  os.WriteString(showTypeColor);  
         os.WriteSize(Tag.STRING | (5 << Tag.TAG_SHIFT));  os.WriteString(des);  
         os.WriteSize(Tag.STRING | (6 << Tag.TAG_SHIFT));  os.WriteString(targetDes);  
         os.WriteSize(Tag.BEAN | (7 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_cfg_task_TriggerType(triggerType,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.BEAN | (8 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_cfg_task_AcceptAction(acceptAction,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.BEAN | (9 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_cfg_task_FinishType(finishType,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.BEAN | (10 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_cfg_bonus_Bonus(reward,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.LIST | (11 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_list_int(taskIds,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         
    }

    public override void UnmarshalCompatible(Perfect.Marshal.Octets os) {
        for (int _var_num_ = os.ReadSize(); _var_num_-- > 0; ) {
            int _id_ = os.ReadSize();
            switch (_id_)
            {
            case (Tag.INT | (1 << Tag.TAG_SHIFT)):   id = os.ReadInt(); break;  
             case (Tag.STRING | (2 << Tag.TAG_SHIFT)):   name = os.ReadString(); break;  
             case (Tag.STRING | (3 << Tag.TAG_SHIFT)):   showTypeName = os.ReadString(); break;  
             case (Tag.STRING | (4 << Tag.TAG_SHIFT)):   showTypeColor = os.ReadString(); break;  
             case (Tag.STRING | (5 << Tag.TAG_SHIFT)):   des = os.ReadString(); break;  
             case (Tag.STRING | (6 << Tag.TAG_SHIFT)):   targetDes = os.ReadString(); break;  
             case (Tag.BEAN | (7 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); triggerType = cfg.Extensions.unmarshal_compatible_cfg_task_TriggerType(os); os = _oldOs; break; }   
             case (Tag.BEAN | (8 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); acceptAction = cfg.Extensions.unmarshal_compatible_cfg_task_AcceptAction(os); os = _oldOs; break; }   
             case (Tag.BEAN | (9 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); finishType = cfg.Extensions.unmarshal_compatible_cfg_task_FinishType(os); os = _oldOs; break; }   
             case (Tag.BEAN | (10 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); reward = cfg.Extensions.unmarshal_compatible_cfg_bonus_Bonus(os); os = _oldOs; break; }   
             case (Tag.LIST | (11 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); taskIds = cfg.Extensions.unmarshal_compatible_list_int(os); os = _oldOs; break; }   
             
            default: Tag.SkipUnknownField(_id_, os); break;
            }
         }
    }
    public override void MarshalXml(XmlWriter ele)
    {
        ele.WriteAttributeString("type", "Linear");
        ele.WriteStartElement("id"); ele.WriteAttributeString("id", "1"); ele.WriteInt(id); ele.WriteEndElement();
         ele.WriteStartElement("name"); ele.WriteAttributeString("id", "2"); ele.WriteString2(name); ele.WriteEndElement();
         ele.WriteStartElement("showTypeName"); ele.WriteAttributeString("id", "3"); ele.WriteString2(showTypeName); ele.WriteEndElement();
         ele.WriteStartElement("showTypeColor"); ele.WriteAttributeString("id", "4"); ele.WriteString2(showTypeColor); ele.WriteEndElement();
         ele.WriteStartElement("des"); ele.WriteAttributeString("id", "5"); ele.WriteString2(des); ele.WriteEndElement();
         ele.WriteStartElement("targetDes"); ele.WriteAttributeString("id", "6"); ele.WriteString2(targetDes); ele.WriteEndElement();
         ele.WriteStartElement("triggerType"); ele.WriteAttributeString("id", "7"); cfg.Extensions.xml_marshal_cfg_task_TriggerType(triggerType,ele); ele.WriteEndElement();
         ele.WriteStartElement("acceptAction"); ele.WriteAttributeString("id", "8"); cfg.Extensions.xml_marshal_cfg_task_AcceptAction(acceptAction,ele); ele.WriteEndElement();
         ele.WriteStartElement("finishType"); ele.WriteAttributeString("id", "9"); cfg.Extensions.xml_marshal_cfg_task_FinishType(finishType,ele); ele.WriteEndElement();
         ele.WriteStartElement("reward"); ele.WriteAttributeString("id", "10"); cfg.Extensions.xml_marshal_cfg_bonus_Bonus(reward,ele); ele.WriteEndElement();
         ele.WriteStartElement("taskIds"); ele.WriteAttributeString("id", "11"); cfg.Extensions.xml_marshal_list_int(taskIds,ele); ele.WriteEndElement();
         
    }

    public override void UnmarshalXml(XmlElement ele)
    {
        foreach (XmlElement e in ele.GetChildren())
        {
            if (int.TryParse(ele.GetAttribute("id"), out var _id_))
            {
                switch (_id_)
                {
                case 1:  id = ele.ReadInt(); break; 
                 case 2:  name = ele.ReadString2(); break; 
                 case 3:  showTypeName = ele.ReadString2(); break; 
                 case 4:  showTypeColor = ele.ReadString2(); break; 
                 case 5:  des = ele.ReadString2(); break; 
                 case 6:  targetDes = ele.ReadString2(); break; 
                 case 7:  triggerType = cfg.Extensions.xml_unmarshal_cfg_task_TriggerType(ele); break; 
                 case 8:  acceptAction = cfg.Extensions.xml_unmarshal_cfg_task_AcceptAction(ele); break; 
                 case 9:  finishType = cfg.Extensions.xml_unmarshal_cfg_task_FinishType(ele); break; 
                 case 10:  reward = cfg.Extensions.xml_unmarshal_cfg_bonus_Bonus(ele); break; 
                 case 11:  taskIds = cfg.Extensions.xml_unmarshal_list_int(ele); break; 
                 
                default: break;
                }
            }
            else
            {
                switch (e.Name)
                {
                case "id":  id = ele.ReadInt(); break; 
                 case "name":  name = ele.ReadString2(); break; 
                 case "show_type_name":  showTypeName = ele.ReadString2(); break; 
                 case "show_type_color":  showTypeColor = ele.ReadString2(); break; 
                 case "des":  des = ele.ReadString2(); break; 
                 case "target_des":  targetDes = ele.ReadString2(); break; 
                 case "trigger_type":  triggerType = cfg.Extensions.xml_unmarshal_cfg_task_TriggerType(ele); break; 
                 case "accept_action":  acceptAction = cfg.Extensions.xml_unmarshal_cfg_task_AcceptAction(ele); break; 
                 case "finish_type":  finishType = cfg.Extensions.xml_unmarshal_cfg_task_FinishType(ele); break; 
                 case "reward":  reward = cfg.Extensions.xml_unmarshal_cfg_bonus_Bonus(ele); break; 
                 case "task_ids":  taskIds = cfg.Extensions.xml_unmarshal_list_int(ele); break; 
                 
                default: break;
                }
            }
        }
    }
}
}
}
